import { defineConfig } from "vite";
import { createVuePlugin } from "vite-plugin-vue2";
import { createHtmlPlugin } from "vite-plugin-html";
import { resolve } from "path";

export default defineConfig({
  base: process.env.NODE_ENV === "local" ? "./" : "",
  plugins: [
    createVuePlugin(),
    createHtmlPlugin({
      minify: true,
      inject: {
        data: {
          title: "",
        },
      },
    }),
  ],
  resolve: {
    extensions: [".vue", ".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"],
    alias: [
      { find: /^~/, replacement: "" },
      { find: "@", replacement: resolve("src") },
      { find: "@basic", replacement: resolve("src/components/basic") },
      { find: "@components", replacement: resolve("src/components") },
    ],
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,

        modifyVars: {
          // 覆盖van默认样式的less文件
          hack: 'true; @import "/src/styles/var.less";',
        },
      },
    },
  },
  server: {
    // proxy: {
    //   [`${PREFIX}`]: {
    //     target: proxyTarget,
    //     changeOrigin: true,
    //     // rewrite: (path) => path.replace(/^\/basic-saas/, ""),
    //   },
    //   [`${MNG_PREFIX}`]: {
    //     target: mngProxyTarget,
    //     changeOrigin: true,
    //     // rewrite: (path) => path.replace(/^\/basic-saas/, ""),
    //   },
    // },
    open: false,
    port: 8086,
    host: true,
  },
});
